//
//  CommentNumCell.m
//  WE
//
//  Created by iMacOne on 15/11/20.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "CommentNumCell.h"
#import "Size.h"
#import "ToolUtil.h"

@interface CommentNumCell ()
@property (nonatomic, strong)UIImageView * aImgeView;
@property (nonatomic, strong)UILabel * disLabel;


@end

@implementation CommentNumCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        self.aImgeView = [[UIImageView alloc] initWithFrame:CGRectMake(margin_10 * Width, margin_10 * Height, margin_20 , margin_20)];
        _aImgeView.layer.masksToBounds = YES;
        _aImgeView.layer.cornerRadius = 10;
        _aImgeView.backgroundColor = [UIColor colorWithRed:0.8756 green:0.6426 blue:0.1394 alpha:1.0];
        _aImgeView.image = [UIImage imageNamed:@"iconfont-lianxizixun"];
        
        self.disLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_aImgeView.frame) + margin_5 * Width, _aImgeView.frame.origin.y, 150, _aImgeView.frame.size.height)];
        _disLabel.font = FONT(14);
        _disLabel.text = @"患者评价(360)";
        
                //
        NSArray * array = [NSArray arrayWithObjects:@"霍纳(41)",@"中耳炎",@"扁桃全体",@"综合征", nil];
        NSArray * array1 = [NSArray arrayWithObjects:@"溃性结肠炎",@"十二指肠溃疡",@"综合征", nil];
        float x = 0;
        for (int i = 0; i < 4; i++) {
            UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
            //            float y = [ToolUtil autoWidth:@"weiieeijljlkjklkj" width:0 height:margin_20 num:12];
            button.titleLabel.font = FONT(12);

            float y = [ToolUtil autoWidth:array[i] width:0 height:margin_20 num:12] + 5;
             x += y;
            
            button.frame = CGRectMake(x - y + (i + 1) * 10, CGRectGetMaxY(self.disLabel.frame) + margin_20, y, margin_20);
            [button addTarget:self action:@selector(doClickButton:) forControlEvents:UIControlEventTouchUpInside];
            //            button.backgroundColor = DEBUG_CLOLR;
            button.tag = 100 + i;
            [button setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
            button.layer.borderWidth = 0.5;
            button.layer.masksToBounds = YES;
            button.layer.cornerRadius = 2;
            button.layer.borderColor = [UIColor grayColor].CGColor;
            [button setTitle:array[i] forState:UIControlStateNormal];
            [self.contentView addSubview:button];
            
        }
        float x1 = 0;
        for (int i = 0; i < 3; i++) {
            float w = [ToolUtil autoWidth:array1[i] width:0 height:margin_20 num:12] + 5;
            UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
            
            x1 += w;
            button.frame = CGRectMake(x1 - w + (i + 1) * 10, CGRectGetMaxY(self.disLabel.frame) + margin_48, w, margin_20);
            button.tag = 200 + i;
            [button addTarget:self action:@selector(doClickButton:) forControlEvents:UIControlEventTouchUpInside];
            button.titleLabel.font = FONT(12);
            [button setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
            button.layer.borderWidth = 0.5;
            button.layer.masksToBounds = YES;
            button.layer.cornerRadius = 2;
            button.layer.borderColor = [UIColor grayColor].CGColor;
            [button setTitle:array1[i] forState:UIControlStateNormal];
            [self.contentView addSubview:button];
            
            
        }
        
        [self.contentView addSubview:_aImgeView];
        [self.contentView addSubview:_disLabel];
        
        
        
    }
    return self;
}

- (void)doClickButton:(UIButton *)btn
{
    
    [self.delegate doClickBtn:btn.tag cell:self];
}



@end
